home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / mouse.exe / MOUSE.DOC < prev    next >
Encoding:
Text File  |  1989-06-03  |  54.7 KB  |  1,357 lines

  1.                            MOUSE V3.1
  2.                         as of 28 May 1989
  3.                        Author: Michael Day
  4.  
  5.    This program is released to the public domain by the author.
  6.  
  7.  
  8.  
  9.  
  10.      Mouse  has gone through a number of major rewrites since  it
  11. was originally introduced. This latest release has changed the way
  12. some  of the functions work. If you are using the  old  mouse
  13. program, you will most likely have to make some minor changes  to
  14. your program to use this new version of Mouse.
  15.  
  16.      The most significant difference is how the mouse positioning
  17. is  being  handled now. In the earlier Mouse program  there  were
  18. separate  routines for the text and graphics  mouse  positioning,
  19. and  separate variables. This is no longer the case.  The  double
  20. routines  have  been merged into single routines with a  flag  to
  21. (TextMouse) control whether the position data is treated as  text
  22. positioning or graphics positioning. Further, new functions  have
  23. been  added to convert the virtual position information  provided
  24. by the mouse back to real screen positioning needed by programs.
  25.  
  26.      To properly set the mouse position, or read the position  of
  27. the  mouse,  you  should now use  the  translation  functions  to
  28. correctly  derive  the proper mouse position on the  screen.  The
  29. advantage   to  this  is  that  the  translation   routines   are
  30. intelligent enough to be able to properly convert the positioning
  31. information  based  on  the current display type  and  mode.  The
  32. standard CGA, EGA, VGA, and Hercules displays and their modes are
  33. supported.  Note: most mouse drivers do not support  extended  or
  34. non-standard  display modes. You may need to override  the  mouse
  35. position translator with your own if you use a non-standard mode.
  36.  
  37.      The other big change is the addition of the simulated  mouse
  38. cursor.  Why a simulated mouse cursor? Two reasons, one,  if  you
  39. don't  have  a mouse, you can still make believe that you  do  by
  40. using  the simulated cursor and keyboard input. And two, it  gets
  41. around a problem with Turbo Pascal in that it is not well behaved
  42. when  it comes to mice. Turbo Pascal and the Turbo Debugger  will
  43. trash  the mouse cursor when using the standard mouse  driver  to
  44. generate  the  cursor.  You  can get around  this  by  using  the
  45. simulated  cursor  instead. Since it operates  via  the  program,
  46. Turbo  Pascal  and  Turbo  Debugger  are  happy.  There  is   one
  47. disadvantage  though, if the simulated mouse is used  the  cursor
  48. operation  will be slow and jerky. I recommend that you  continue
  49. to   use  the  driver  generated  mouse  cursor  for   commercial
  50. applications  where  possible. The simulated mouse is  mainly  to
  51. allow  you to use a mouse while debugging a program or to  run  a
  52. program without a mouse at all.
  53.  
  54.  
  55.  
  56. ISR Support:
  57.  
  58.      Another  addition is ISR support for the mouse so  that  you
  59. don't have to sprinkle ReadMouse calls through out your  program.
  60. This can make mouse programming much simpler.
  61.  
  62.  
  63.  
  64. Graphic Mouse Cursor:
  65.  
  66.      There are 19 supplied Graphic mouse cursors in the  program.
  67. You   can   select   the   desired   cursor   by   calling    the
  68. MouseGraphicCursor function which will cause the selected  cursor
  69. to  be loaded from the table. You can see which cursor  has  been
  70. loaded  by  looking  at  the  global  MouseGStyle  variable.   If
  71. MouseGStyle contains a -1 it means that a custom cursor has  been
  72. loaded.  You  can load your own custom graphic  mouse  cursor  by
  73. using the SetMouseGraphicCursor function.
  74.  
  75.  
  76.  
  77. Text Mouse Cursor:
  78.  
  79.      There are 16 supplied Text mouse cursors in the program. You
  80. can  select  the desired cursor by  calling  the  MouseTextCursor
  81. function  which will cause the selected cursor to be loaded  from
  82. the table. You can see which cursor has been loaded by looking at
  83. the global MouseTStyle variable. If MouseTStyle contains a -1  it
  84. means  that  a  custom cursor has  been  loaded.  If  MouseTStyle
  85. contains  a 0, then the current hardware cursor is used. You  can
  86. load   your   own  custom  text  mouse  cursor   by   using   the
  87. SetMouseTextCursor function.
  88.  
  89.      The  TextMouse flag is used to identified whether the  mouse
  90. is  currently  in text or graphics mode.  Calling  the  MouseInit
  91. procedure  will cause the TextMouse flag to be set based  on  the
  92. value found in the BIOS CrtMode flag.
  93.  
  94.      if  you  are using a non-standard or extended  display  mode
  95. (graphic  or text), the mouse position translation  routines  may
  96. not  be  able to correctly translate the screen position  to  the
  97. virtual mouse position used by the mouse driver. You can  however
  98. override  the  mouse  position control  variables  after  calling
  99. InitMouse to perform your own translation.
  100.  
  101.  
  102.  
  103. Mouse Installation:
  104.  
  105.      The  Mouse program expects a MicroSoft or  compatible  mouse
  106. driver to be installed on the computer. All mouse operations  are
  107. performed through the mouse interrupt ($33). For more information
  108. on  using  the  mouse  interrupt refer  to  the  MicroSoft  Mouse
  109. Programmer's  Reference Guide available from MicroSoft or  though
  110. various computer book stores.
  111.  
  112.      If  the  mouse  driver  has not  been  installed,  then  the
  113. InitMouse procedure will set the MouseInstalled flag to false and
  114. most  mouse procedures will immediately terminate if called.  The
  115. basic  mouse functions will continue to operate however  if  your
  116. program   updates  the  MouseX  and  MouseY   mouse   positioning
  117. variables.  This allows keyboard mouse emulation if the mouse  is
  118. not available.
  119.  
  120.  
  121.  
  122. Starting out:
  123.  
  124.      The first thing to do to get the mouse going is to call  the
  125. InitMouse function near the beginning of your program before  you
  126. use the other mouse functions.
  127.  
  128.      The  InitMouse  function initailizes the mouse driver  to  a
  129. predefined state. You can call the InitMouse function at anytime,
  130. but you should realize that any previous state will be lost.
  131.  
  132.      Special note about Hercules:
  133.  
  134.           If  you  are using a Hercules display,  then  you  must
  135.      call the SetHercMouse function before calling the  InitMouse
  136.      function.  This is because the mouse driver must know  which
  137.      display  page and mode of the Hercules card you  are  using.
  138.      Also be sure to call the SetHercMouse function with a -1  to
  139.      return  it to text mode when you switch back to  text  mode.
  140.      An  exit  procedure has been provided in  Mouse  which  will
  141.      properly restore the function when you exit your program.
  142.  
  143.           The  reason  for  this special  handling  is  that  the
  144.      hercules  card  does not provide any way for the  system  to
  145.      know  if  it  is in text mode or graphics mode,  and  if  in
  146.      graphics  mode  which  page  is  selected.  As  such,   this
  147.      information  must  be  maintain by  the  user  program.  The
  148.      MicroSoft  mouse  driver uses the CrtMode variable  to  find
  149.      this  information  and leaves it up to the user  program  to
  150.      properly set the variable for desired operation.
  151.  
  152.  
  153.  
  154.  
  155. Showing the Mouse:
  156.  
  157.      Once you have the mouse initialized, You can make it  appear
  158. on the screen by calling the ShowMouse function.
  159.  
  160.      If the mouse was previously hidden, you must call  ShowMouse
  161. the  same  number of times that you called HideMouse to  get  the
  162. mouse to appear.
  163.  
  164.  
  165.  
  166. Hiding the Mouse:
  167.  
  168.      To  hide the mouse cursor you call the  HideMouse  function.
  169. You can call the HideMouse function multiple times. If the  mouse
  170. is currently visible it will be immediately hidden. If the  mouse
  171. cursor is not visible then a counter is decremented. To make  the
  172. mouse  visible again you must call ShowMouse the same number  (or
  173. more) times as you called HideMouse.
  174.  
  175.      Remember that InitMouse will always restore the mouse to the
  176. first  hidden level requiring only a single call to ShowMouse  to
  177. make the mouse cursor visible.
  178.  
  179.      Hiding the mouse does not disable the mouse, it only  causes
  180. the  mouse  cursor to not be displayed. All mouse  functions  are
  181. still fully operational. If the mouse is moved the mouse position
  182. will be updated even if the cursor is hidden.
  183.  
  184.      Remember,  *always*  hide the mouse before  writing  to  the
  185. screen.  Failure to do so can cause the screen to  be  disrupted.
  186. This is particularly true if you are using an ISR, since the  ISR
  187. assumes that if the mouse is visible it is ok to update the mouse
  188. cursor position.
  189.  
  190.  
  191. Reading the Mouse Position:
  192.  
  193.      There  are  two ways to handle reading the  mouse.  You  can
  194. either  used the old polled method which since it operates  fully
  195. under  program control keeps you out of trouble, or you  can  use
  196. the included ISR to perform the activity as a background task.
  197.  
  198.  
  199. Polled Mouse:
  200.  
  201.      In  the polled method you can locate the mouse by placing  a
  202. call  to  the  ReadMouse function. The  ReadMouse  function  will
  203. update  the  current  mouse position variables each  time  it  is
  204. called.  Thsi  has  the  disadvantage that  you  must  place  the
  205. ReadMouse  call  in  the program where it will  be  called  often
  206. enough  to  keep  the  variables updated  at  a  desirable  rate.
  207. Sometimes  this  entails  "sprinkling"  the  ReadMouse  calls  in
  208. various critical parts of the program.
  209.  
  210.  
  211. ISR Mouse:
  212.  
  213.      An  alternate  approach  is to use an  ISR  to  perform  the
  214. function. There are two types of ISRs that can be used. One  that
  215. is  generated by the mouse itself when ever an action occurs,  or
  216. one by the system that periodically checks the mouse status.  The
  217. Mouse unit comes with a system generated ISR that ties in to  the
  218. system  clock to periodically update the mouse once  every  55ms.
  219. This has the advantage that mouse drivers that do not support the
  220. Mouse ISR functions.
  221.  
  222.  
  223. ISR programming:
  224.  
  225.      Remember  when  using program based ISRs you are  using  re-
  226. entrant  coding.  You must use extreme care that you do  not  use
  227. functions  inside  the  ISR which are  not  re-entrant.  This  is
  228. because the ISR is entered via an interrupt, which means that you
  229. do  not  know  where  it  came from.  It  could  very  well  have
  230. interrupted  the program in the middle of a routine that  is  not
  231. re-enterable.  The  provided  ISR function  uses  the  ReadMouse,
  232. ShowMouse,  and HideMouse functions. Thus be very careful if  you
  233. change these procedures so that they do not conflict with the ISR
  234. itself.
  235.  
  236.      The ReadMouse, ShowMouse, and HideMouse procedures all  have
  237. a  re-entrant  test  at the beginning to  prevent  the  ISR  from
  238. entering the function if it is currently in use. This is required
  239. because the procedures are not re-entrant.
  240.  
  241.      Since  the  mouse  routines are not  re-entrant,  all  other
  242. procedures that use the mouse set a flag which is used to inhibit
  243. the  mouse ISR from entering them. Not that the Graphics  library
  244. functions  are not re-enterable, this means that you  cannot  use
  245. the  HideMouseArea function when using the ISR. This  is  because
  246. with  the HideMouseArea function, it is possible to write to  the
  247. display while the mouse is visible since the mouse is only hidden
  248. when  it  is in the update area. This action  is  not  acceptable
  249. since that means that the mouse would be on the screen while  you
  250. are  changing the display, and that means an interrupt can  occur
  251. within  a graphics library function, with a mouse  cursor  update
  252. generated by the ISR.
  253.  
  254.      There  is also the problem that the Turbo  graphics  library
  255. does  not  use the extended EGA function calls the  set  the  EGA
  256. registers  when the mouse is present so that the mouse  can  keep
  257. track  of  the register status (many critical EGA  registers  are
  258. non-readable). This will also cause problems. As a general  rule,
  259. it  is best to avoid using the HideMouseArea function unless  you
  260. are absolutely sure of your program and it's environment. Use the
  261. Generic HideMouse function instead. You'll probably save yourself
  262. a lot of headaches.
  263.  
  264.  
  265.  
  266. Mouse Positioning:
  267.  
  268.      The  value returned in the mouse position variables  depends
  269. on whether the TextMouse flag is true or false. If true, then the
  270. values  will be related to the character position on the  screen.
  271. If  the TextMouse flag is false, then it will be related  to  the
  272. graphic pixel position. The button information is also  returned,
  273. and  if a button was pressed, the action is noted, and the  mouse
  274. position at the time it was pressed is saved.
  275.  
  276.  
  277. Mouse simulation:
  278.  
  279.      If  the mouse is not available, then the  mouse  positioning
  280. can  be  set  by  the program.  calling  the  ReadMouse  function
  281. periodically  in your program will maintain the  simulated  mouse
  282. positioning information. If the mouse simulation is enabled, then
  283. a  simulated mouse cursor will be displayed. The simulated  mouse
  284. cursor will be updated on the display each time the mouse  cursor
  285. position information is changed either by the mouse itself, or by
  286. the program placing new values in the MouseX and MouseY  position
  287. variables.
  288.  
  289.      If  the  mouse  is available, and the  mouse  simulation  is
  290. enabled,  then  the simulated cursor will track  the  mouse.  The
  291. tracking is performed by the ReadMouse function. Each time it  is
  292. called, the mouse cursor is updated if it has moved.
  293.  
  294.  
  295.  
  296. Text verses Graphic positioning:
  297.  
  298.      When  the  InitMouse  function is called, it  looks  at  the
  299. BIOS  CrtMode flag to determine how to set the mouse  positioning
  300. information.  Various  flags and registers are set based  on  the
  301. information  read from the BIOS. For non-standard  displays  that
  302. the InitMouse procedure cannot adapt to, the flags and  registers
  303. can  be  overwritten by the user program after the  call  to  the
  304. InitMouse procedure.
  305.  
  306.  
  307.  
  308. Public variables:
  309.  
  310.      A  number  of variables in the Mouse unit are  available  to
  311. to  programs that use it. They are provided to allow the  program
  312. to determine the current status of the mouse and/or to be able to
  313. override the default values selected by the InitMouse procedure.
  314.  
  315.  
  316. CrtMode : Byte absolute $40:$49;      {BIOS Crt mode flag}
  317. CrtCols : Word absolute $40:$4A;      {BIOS Crt col cnt}
  318. CrtRows : Byte absolute $40:$84;      {BIOS Crt row cnt}
  319. SysClk  : Word absolute $40:$6C;      {BIOS system clock counter}
  320. CursorMode : Word absolute $40:$60;   {BIOS cursor mode storage}
  321.  
  322.      There  are  five BIOS variables used by the  mouse  unit  to
  323. determine  the type and mode of the display. These variables  are
  324. used  to determine the mouse position translation values to  use.
  325. The   InitMouse  procedure  uses  these  values  to  update   the
  326. MouseText, MouseTextWidth, MouseTextHeight, MaxCrtX, MaxCrtY, and
  327. ZeroMouse  variables.  They are provided as public  variables  so
  328. that  the programs which use the Mouse unit can also have  access
  329. to them.
  330.  
  331.  
  332. MouseInstalled : Boolean; {InitMouse - True if mouse is operable}
  333.  
  334.      If  a  Mouse  was detected by the  InitMouse  procedure  the
  335. MouseInstalled flag will be set to true. If a Mouse is not found,
  336. then  the  flag  is  set to false. If  you  wish  to  temporarily
  337. disconnect  the mouse routines you can set the flag to  false  at
  338. anytime after calling InitMouse. This will not disable the mouse,
  339. only  the  calls  to the mouse in the Mouse unit.  If  the  mouse
  340. cursor  is  currently  being displayed, and  the  external  mouse
  341. driver  is  being  used to update the cursor  position,  it  will
  342. continue  to  maintain the cursor on the screen. The  MouseX  and
  343. MouseY  position variables are only updated from the  mouse  when
  344. the MouseInstalled flag is true.
  345.  
  346.  
  347. MouseError : Integer;                    {InitMouse - Error code}
  348.  
  349.      The  MouseError flag is used to determine why the  mouse  is
  350. not  available. The variable is updated each time  the  InitMouse
  351. procedure  is  called.  A value of -1 means  that  the  mouse  is
  352. available.   Generally  If  the  MouseError  flag  is   -1,   the
  353. MouseInstalled  flag will be true unless your program has  turned
  354. the MouseInstalled flag off for some reason.
  355.  
  356.      If  there was no mouse driver found to be installed  in  the
  357. computer  (as  determined  by not finding a  driver  attached  to
  358. interrupt  $33)  the MouseError variable will be set to 1.  If  a
  359. driver is available, but no mouse was found, then the  MouseError
  360. variable is set to 0.
  361.  
  362.  
  363. MouseType : Integer;                     {InitMouse - Mouse Type}
  364.  
  365.      The  MouseType  variable  tells you what kind  of  mouse  is
  366. attached  to the computer. If no mouse is found the  variable  is
  367. set to 0. If a single button mouse is found it is set to 1. It is
  368. set  to  2 for a two button mouse, and three for a  three  button
  369. mouse.
  370.  
  371. MouseClicked : Boolean;  {ReadMouse - True if button was clicked}
  372.  
  373.      The MouseClicked variable indicates when a mouse button  has
  374. been pressed. The flag is provided as a public variable primarily
  375. to  allow mouse simulation programming to set or clear the  flag.
  376. Normally you should use the MouseClick function to determine  the
  377. condition of the MouseClicked flag since it automatically  clears
  378. the flag in preparation for the next click.
  379.  
  380.  
  381. MouseButtons : Word;    {ReadMouse - Current mouse button status}
  382.  
  383.      Each  time  the ReadMouse function is called, this  flag  is
  384. updated with the current mouse button status. You can look at the
  385. flag at any time to determine the current state of the buttons.
  386.  
  387.  
  388. MouseClickButton : Word;        {ReadMouse - Click button status}
  389.  
  390.      The  MouseClickButton variable is updated by  the  ReadMouse
  391. function.  The  variable  is updated by  the  ReadMouse  function
  392. whenever a new mouse button is pressed.
  393.  
  394.  
  395.  
  396.  
  397. MouseX : Integer;                  {ReadMouse - Mouse X Position}
  398. MouseY : Integer;                  {ReadMouse - Mouse Y Position}
  399.  
  400.      The  MouseX and MouseY variables are updated each  time  the
  401. ReadMouse procedure is called. The variables reflect the  current
  402. mouse position at the time that the mouse is interrogated via the
  403. ReadMouse function. In the case where the MouseInstalled flag  is
  404. set to false the variables are not updated, however if the  mouse
  405. simulator  is enabled the simulated mouse position on the  screen
  406. will  be  updated  based on the values found in  the  MouseX  and
  407. MouseY variables each time the ReadMouse function is called.
  408.      Calling   the  SetMousePosition  procedure  will  load   new
  409. position  information in the variables. Thus if your  program  is
  410. simulating a mouse, it can use the SetMousePosition procedure  to
  411. update  the variables, and use the ReadMouse procedure to  update
  412. the simulated cursor on the screen.
  413.  
  414.  
  415.  
  416. ClickMouseX : Integer;                   {Mouse X Click Position}
  417. ClickMouseY : Integer;                   {Mouse Y Click Position}
  418.  
  419.      The ClickMouseX and ClickMouseY variables are updated by the
  420. ReadMouse routine when ever a button it pressed. They reflect the
  421. current  mouse position at the time the button was pressed.  They
  422. are only updated when the button is depressed. The button must be
  423. released before the variables will be updated again.
  424.  
  425.  
  426.  
  427. MousePressX : Integer;       {last mouse button pressed position}
  428. MousePressY : Integer;
  429.  
  430.      The MousePress function returns the information provided  by
  431. the associated mouse driver function.  The position the mouse was
  432. in at the last time the specified button was pressed is  returned
  433. in the MousePressX and MousePressY variables. These values are in
  434. the mouse driver virtual format. You can use the GetMx and  GetMy
  435. functions   to  convert  the  values  to  real  screen   position
  436. information.
  437.  
  438.  
  439.  
  440.  
  441. MouseReleaseX : Integer;     {last mouse button release position}
  442. MouseReleaseY : Integer;
  443.  
  444.      The  MouseRelease function returns the information  provided
  445. by the associated mouse driver function.  The position the  mouse
  446. was  in  at the last time the specified button  was  released  is
  447. returned  in  the MousePressX and  MousePressY  variables.  These
  448. values  are in the mouse driver virtual format. You can  use  the
  449. GetMx  and GetMy functions to convert the values to  real  screen
  450. position information.
  451.  
  452.  
  453.  
  454.  
  455. MouseHideX1 : Integer;          {HideMouseArea - Mouse hide area}
  456. MouseHideY1 : Integer;
  457. MouseHideX2 : Integer;
  458. MouseHideY2 : Integer;
  459.  
  460.      The   MouseHide   variables  reflect   the   current   mouse
  461. conditional  hiding  area.  The conditional  hide  is  a  special
  462. function that is not available with all mouse drivers, and it has
  463. problems  with  EGA displays unless a special BIOS  interface  is
  464. used. The variables are set by the HideMouseArea procedure.
  465.  
  466.  
  467.      Since  programs  generated by the Borland compilers  do  not
  468. make use of the special BIOS routines, it is recommended that you
  469. do  not  use the conditional hide if you are using  an  EGA  mode
  470. display.  If the mouse simulator is being used,  the  conditional
  471. Mouse  hiding will work properly since we have full control  over
  472. the mouse. It is only when the external mouse driver is used that
  473. the  problem exists.
  474.  
  475.      An  exception is if you are using a mouse ISR. In this  case
  476. you should not use the simulated mouse cursor because the Borland
  477. graphics  library  and screen controls are not re-entrant.  As  a
  478. general  rule, if you aren't sure, stay away from this  function.
  479. It's not worth the headaches.
  480.  
  481.  
  482.  
  483.  
  484. MouseAreaX1 : Integer;        {SetMouseArea - Mouse bounded area}
  485. MouseAreaY1 : Integer;
  486. MouseAreaX2 : Integer;
  487. MouseAreaY2 : Integer;
  488.  
  489.      The MouseArea variables contain the limits that the mouse is
  490. allowed to travel within on the screen. The mouse cursor will not
  491. travel   outside  this  area.  The  variables  are  set  by   the
  492. SetMouseArea procedure.
  493.  
  494.  
  495.  
  496. MouseGStyle : Integer = 1;         {selected graphic mouse style}
  497.  
  498.      The  MouseGStyle  variable  indicates  which  graphic  mouse
  499. cursor  is  currently being used. When InitMouse  is  called  the
  500. mouse  cursor is always returned to style type one. The  variable
  501. is also updated by the MouseGraphicCursor procedure. If a  custom
  502. mouse cursor is loaded by the SetMouseGraphicCursor procedure the
  503. MouseStyle variable will be set to -1.
  504.  
  505.  
  506. MouseTStyle : Integer = 0;            {selected text mouse style}
  507.  
  508.      The  MouseTStyle variable indicates which text mouse  cursor
  509. is  currently  being  used. When InitMouse is  called  the  mouse
  510. cursor  is  always returned to style type zero. The  variable  is
  511. also updated by the MouseTextCursor procedure. If a custom  mouse
  512. cursor   is  loaded  by  the  SetMouseTextCursor  procedure   the
  513. MouseStyle variable will be set to -1. If a style type of zero is
  514. used,  then the current existing hardware cursor is used  as  the
  515. mouse cursor.
  516.  
  517.  
  518. MouseState : Integer = -1;              {Negative = mouse hidden}
  519.  
  520.      The MouseState variable is used by Mouse unit to keep  track
  521. of  the  mouse  cursor  condition. It normally  will  take  on  a
  522. negative  value  if the mouse is hidden, or a value of 0  if  the
  523. mouse  is visible. The MouseState variable is decremented by  one
  524. each  time the HideMouse function is called, and  incremented  by
  525. one each time the ShowMouse function is called. It never achieves
  526. a value higher than zero.  You should never change this  variable
  527. with your program it is provided for informational purposes only.
  528.  
  529.  
  530. MouseVisible : Boolean = false;         {true = mouse is visible}
  531.  
  532.      When the Mouse is visible on the screen this flag is set  to
  533. true.  When  the  mouse is hidden it is set to  false.  The  flag
  534. should  not  be changed by your program. It is provided  only  so
  535. that you can determine the current state of the mouse cursor. The
  536. HideMouse  and  ShowMouse procedures are used to make  the  mouse
  537. visible or to hide it.
  538.  
  539.  
  540. MouseCondo : Boolean = false;   {true = conditional mouse hiding}
  541.  
  542.      When the Mouse is operating in the conditional hide state as
  543. specified by calling procedure MouseAreaHide, the MouseCondo flag
  544. is set true. Normal mouse operation will cause the flag to be set
  545. to  false. The flag should not be changed by your program  it  is
  546. provided  only as a means to determine the current state  of  the
  547. mouse area hide condition.
  548.  
  549.  
  550.  
  551.  
  552. MouseReDraw : Boolean = false; {true = mouse needs to be redrawn}
  553.  
  554.      The MouseReDraw flag is used by the mouse cursor  simulator.
  555. When  it is true, it forces the mouse cursor to be redrawn.  This
  556. flag  can  be  set  by your program to force  the  cursor  to  be
  557. redrawn.  It  is set internally anytime the  mouse  cursor  bumps
  558. against the edge of the screen while the simulated BGI cursor  is
  559. being  used.
  560.  
  561.      The  reason  behind this is because the  BGI  driver  cannot
  562. handle  images being drawn outside the screen. Thus in  order  to
  563. allow  the  mouse cursor to move off the edge of the  screen,  it
  564. must be redrawn each time to adjust the cursor image to the  area
  565. of the screen that it can be displayed on. This flag should never
  566. be  set to false by your program. You can however set it to  true
  567. if you have a need to do so.
  568.  
  569.  
  570.  
  571. TextMouse : Boolean = false;        {true = text mode type mouse}
  572.  
  573.      The  TextMouse  flag  is  set by a  call  to  the  InitMouse
  574. procedure.  If one of the standard text modes is  determined  (as
  575. found  by  seeing  a value less than 4 or a value  of  7  in  the
  576. CrtMode byte), the TextMouse flag is set to true. Otherwise it is
  577. set  to false. If you are using a custom display text  mode  then
  578. you  may  need  to  set  this flag to  true  after  the  call  to
  579. InitMouse.
  580.  
  581.  
  582.  
  583. ZeroMouse : Boolean = false;      {true = text mouse starts at 0}
  584.  
  585.      The ZeroMouse flag controls whether the mouse positioning is
  586. zero  based  or one based. That is, whether the  screen  position
  587. starts at location 0,0 or 1,1. The 0,0 starting position is  used
  588. during  graphics  mode, while the 1,1 starting position  is  used
  589. during  text  mode. If you are using a text  mode  that  performs
  590. positioning  starting  at 0,0 you can set the ZeroMouse  flag  to
  591. false after calling InitMouse.
  592.  
  593.  
  594.  
  595. HercGraphMouse : Boolean = false;  {true = Herc graph mode mouse}
  596.  
  597.      When A Hercules display is used in graphics mode, this  flag
  598. is set to true. The function SetHercGraph controls this flag. You
  599. should  not  set this flag directly. it should only be set  by  a
  600. call to SetHercGraph. You can however use it to determine if  the
  601. mouse is operating in the Hercules Graphics mode.
  602.  
  603.  
  604.  
  605.  
  606. MouseTextWidth  : Word = 8;    {size of text on screen for mouse}
  607. MouseTextHeight : Word = 8;
  608.  
  609.      The MouseTextWidth and MouseTextHeight variables contain the
  610. size of the text characters on the screen. These values are  used
  611. to  convert  from the mouse virtual position information  to  the
  612. real screen information, or from real screen position information
  613. to the virtual mouse position information.
  614.      The  MouseText size values are set when a call is placed  to
  615. the InitMouse procedure. If the default values determined by  the
  616. InitMouse procedure do not match those that you are using you can
  617. change  the  values  at  anytime  after  calling  the   InitMouse
  618. procedure to set them to the desired values.
  619.  
  620.  
  621.  
  622.  
  623. MaxCrtX : Word = 80;                {Maximum size of text screen}
  624. MaxCrtY : Word = 25;
  625.  
  626.      The  MaxCrtX and MaxCrtY variables are set by the  InitMouse
  627. function.  The  values  are  based on those  found  in  the  BIOS
  628. variables  CrtCols,  and CrtRows. These secondary  variables  are
  629. used   because   the  BIOS  variables  do  not   always   contain
  630. proper  values. The InitMouse procedure adjusts for  the  correct
  631. values based on the machine and display being used.
  632.  
  633.  
  634.  
  635.  
  636. MouseColor : Word = white;                   {mouse cursor color}
  637.  
  638.      When you use the BGI simulated mouse cursor you have control
  639. over  the mouse cursor color. The MouseColor variable  determines
  640. the  color  of the simulated mouse cursor. You  can  change  this
  641. variable  at any time. It is defaulted to white when the  program
  642. starts.  Since  this is a typed variable, you can  change  it  to
  643. start with any value you wish, or you can change it at run  time
  644. to a desired color.
  645.      The  MouseColor  variable  has  no  effect  on  the   cursor
  646. generated  by the standard mouse driver. The mouse driver  always
  647. generates a white cursor.
  648.  
  649.  
  650.  
  651. UseMouseSim : Boolean = false;{true = use simulated mouse cursor}
  652.  
  653.      The UseMouseSim flag is a user flag that you can set to true
  654. or false. When true the simulated mouse cursor will be used. When
  655. false  the  Mouse  driver's own cursor will be  used.  The  mouse
  656. cursor  should always be off before changing this flag.  You  can
  657. change  the  condition  of the flag at any time  that  the  mouse
  658. cursor is not visible.
  659.  
  660.  
  661. MouseImageX  : Integer = 0;     {current mouse XY image position}
  662. MouseImageY  : Integer = 0;
  663.  
  664. The  MouseImageX and MouseImageY position variables are  provided
  665. to allow you to know where the simulated BGI mouse image actually
  666. is  on  the  screen.  The  mouse  position  is  determined  by  a
  667. combination of the "Hot Spot" location and the upper left  corner
  668. of  the  mouse  image.  Adding the two  values  will  reveal  the
  669. location  of  the  mouse cursor Hot Spot  on  the  screen.  These
  670. variables  are provided for informational use only.  They  should
  671. not  be changed by the user program since doing so  will  disrupt
  672. the mouse simulator.
  673.  
  674.  
  675. MaskType = record                      {mouse graphic cursor def}
  676.              Def: array [0..1, 0..15] of word; {graph cursor def}
  677.              HotX, HotY: integer;                  {hot spot X,Y}
  678.            end;
  679.  
  680.      The  MaskType  defines how a custom graphic  cursor  can  be
  681. created. The mouse cursor mask consists of two arrays of 16 words
  682. each. The first array is the mask value that is used to turn  off
  683. selected bits under the mouse cursor, and the second array of  16
  684. words contains the mask value that is used to generate the cursor
  685. in the foreground. The first word in the array is the top line of
  686. the cursor, the last word in the array is the bottom line of  the
  687. cursor.
  688.  
  689.      The  "hot  spot", which is the location related to  the  top
  690. left  corner  of the mouse cursor image, specifies  the  location
  691. where all mouse activity is tied to. The HotX and HotY values are
  692. relative to the top left corner of the mouse image.
  693.  
  694.      You  can use the SetMouseGraphic cursor to define  a  custom
  695. mouse cursor of your own.
  696.  
  697.  
  698. MouseTextType = record
  699.                   Select : Word;             {soft or hard mouse}
  700.                   Start  : Word;         {mouse start definition}
  701.                   Stop   : Word;           {mouse end definition}
  702.                 end;
  703.  
  704.  
  705.      The  MouseTextType  defines what a text mouse  cursor  looks
  706. like.  The Select value determines whether it will be a  hardware
  707. cursor,  or a software cursor. Start is the starting cursor  line
  708. for  a  hardware cursor, or the and mask for a  software  cursor.
  709. Stop  is the ending cursor line for a hardware cursor, or the  OR
  710. mask for a software cursor.
  711.  
  712.  
  713.      Refer to the mouse programmer's manual for more  information
  714. on programming a mouse cursor.
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731. Local variables:
  732.  
  733.      In  addition to the public variables, there are  some  local
  734. variables  used by the Mouse unit. The definitions  are  provided
  735. here for reference purposes only.
  736.  
  737.  
  738.  
  739.  
  740. MouseBusy  : Boolean;                 {Mouse routines are in use}
  741.  
  742.      The  MouseBusy  flag  is set when ever a  mouse  routine  is
  743. entered.  This  is  used  to notify an  ISR  that  the  mouse  is
  744. currently in use and should not be disturbed.
  745.  
  746.  
  747.  
  748.  
  749. OldMouseX  : Integer;                 {Previous mouse X Position}
  750. OldMouseY  : Integer;                 {Previous mouse Y Position}
  751.  
  752.      The  OldMouse variables are used by the ReadMouse  procedure
  753. to determine when the mouse has moved. When the values stored  in
  754. OldMouseX  and OldMouseY no longer match the new values found  in
  755. MouseX and MouseY then simulate mouse cursor is updated if it  is
  756. enabled. The variables are available for the program to look  at,
  757. but  don't change the values since it will disrupt the  simulated
  758. cursor display.
  759.  
  760.  
  761.  
  762. CustomMask : MaskType;   {storage for custom graphic cursor data}
  763.  
  764.      When  a custom graphic mouse cursor is loaded it  is  saved,
  765. in  this  variable  is updated so that the  simulated  BGI  mouse
  766. cursor  can have access to the data. This record should never  be
  767. loaded   directly.  You  should  use  the   SetMouseGraphicCursor
  768. procedure to update the data in this record.
  769.  
  770.  
  771.  
  772.  
  773. MouseReg : Registers;    {registers used to call mouse interrupt}
  774.  
  775.      The  MouseReg  variables  are  used  by  the  mouse   driver
  776. interface  routines  when  placing calls to and  from  the  mouse
  777. interrupt  driver. The Registers type used by this record is  the
  778. only reason that the Dos unit is used by the Mouse Unit. They are
  779. declared as a private global variable so that time is not  wasted
  780. creating the variables on the stack each time a mouse routine  is
  781. called.
  782.  
  783.  
  784.  
  785. MouseTemp : Integer = 0;            {Temp mouse storage variable}
  786.  
  787.      MouseTemp  is  just a fast access temporary  local  variable
  788. used by the simulated mouse cursor routines. Beyond that, it  has
  789. not specific purpose.
  790.  
  791.  
  792.  
  793. MouseStack : MousePtrP;  {MouseStack points to last rec on stack}
  794.                           {if nil then there is nothing on stack}
  795.  
  796.      The  MouseStack  is  used  by  the  PushMouse  and  PopMouse
  797. functions.  Note:  Not all mouse drivers support the  ability  to
  798. save  and restore the mouse status. You should check  your  mouse
  799. driver  before  using  these functions.  Never  ever  attempt  to
  800. directly  access the data on the mouse stack since it  may  cause
  801. the program to crash, or at least disrupt the mouse itself.
  802.  
  803.  
  804.  
  805. Local BGI graphic variables
  806.  
  807.      The  following variables are used locally by  the  simulated
  808. BGI mouse cursor functions.
  809.  
  810.  
  811. MouseBack : pointer = nil;    {^old image under BGI mouse cursor}
  812. MouseMask : pointer = nil;               {^BGI mouse cursor mask}
  813. MouseFore : pointer = nil;            {^BGI mouse cursor overlay}
  814. MouseSize : word = 0;      {storage size for mouse image 0=empty}
  815.  
  816.      The MouseBack, MouseMask, and MouseFore pointers contain the
  817. pointers  to  where  the  mouse images are  saved  on  the  heap.
  818. MouseBack  contains  the screen image that is behind  the  mouse.
  819. MouseMask contains the AND mask used to blank out selected screen
  820. areas  under the mouse cursor, and MouseFore contains  the  mouse
  821. cursor  foreground image. MouseSize specifies how big  the  mouse
  822. image is. All four variables are updated each time the  InitMouse
  823. function is called.
  824.  
  825.  
  826. EndImageX : Integer = 0;       {End of Mouse X image}
  827. EndImageY : Integer = 0;       {End of Mouse Y image}
  828.  
  829.      The  EndImage variables are used by the simulated BGI  mouse
  830. cursor to determine where the end of the mouse cursor image is on
  831. the screen.
  832.  
  833.  
  834. OldImageX : integer = 0;       {position of image under mouse }
  835. OldImageY : integer = 0;
  836.  
  837.      The  OldImage variables are used to keep track of  the  last
  838. known  position  of the mouse cursor. This is used when  the  old
  839. mouse cursor is undrawn before it is moved to its new location.
  840.  
  841.  
  842. Available Mouse Functions:
  843.  
  844.      The  following mouse functions are available to the  program
  845. using  the  Mouse  Unit.  For  More  information  on  the   mouse
  846. functions,  refer to the MicroSoft Mouse  Programmer's  technical
  847. Reference Guide.
  848.  
  849.  
  850. { Function 0 - Initialize mouse software and hardware }
  851. procedure InitMouse;
  852.  
  853.      The InitMouse procedure is used to initialize the mouse when
  854. ever the program is first started or the display mode is changed.
  855. This  keeps  the internal mouse information synchronized  to  the
  856. display in use.
  857.  
  858.  
  859.  
  860.  
  861. { Function 1 - show mouse cursor }
  862. procedure ShowMouse;
  863.  
  864.      The ShowMouse function is called to display the mouse. If  a
  865. previous HideMouse was called, the same number of ShowMouse calls
  866. must be performed to show the mouse.
  867.  
  868.  
  869.  
  870.  
  871. { Function 2 - hide mouse cursor }
  872. procedure HideMouse;
  873.  
  874.      The HideMouse function hides the mouse cursor. This does not
  875. disable the mouse, it only hides the cursor. All mouse  functions
  876. continue  to operate normally. Use this function  before  writing
  877. to the screen so that the mouse cursor won't be disrupted.
  878.  
  879.  
  880.  
  881. { Function 3 - read mouse position and button status }
  882. { Use GetMx, GetMy to read the mouse position info in MouseX, MouseY, }
  883. { or ClickMouseX, ClickMouseY }
  884. procedure ReadMouse;
  885.  
  886.      The  ReadMouse  function should be  called  periodically  to
  887. update the program's mouse variables. Each time this function  is
  888. called,  the mouse is interrogated and the variables  updated  on
  889. the  results.  If the mouse has moved, and  the  simulated  mouse
  890. cursor  is  being used, then the mouse cursor will  be  moved  to
  891. reflect the new position.
  892.  
  893.      The ReadMouse function should be called periodically by your
  894. program to insure that the mouse variables are properly  updated.
  895. A good place to call the function is in the same routine that you
  896. use to check for keyboard input. Alternately you could attach  it
  897. to an ISR service routine to update the variables automatically.
  898.  
  899.  
  900.  
  901.  
  902. { function 4 - sets mouse position }
  903. { Recommended calling method: }
  904. { SetMousePosition(PutMx(X),PutMy(Y)); }
  905. procedure SetMousePosition(X,Y:Integer);
  906.  
  907.      The SetMousePostion function places the mouse cursor at  the
  908. specified  position  on the display. This  function  expects  the
  909. virtual  mouse coordinates to be used. Normally this  means  that
  910. you  should use the PutMx and PutMy functions to adapt  your  own
  911. screen  position  information to the values wanted by  the  mouse
  912. driver.
  913.  
  914.  
  915.  
  916.  
  917. { function 5 - gets button press information  }
  918. { Recommended calling method: }
  919. { Status := MousePress(Button,Count); }
  920. { Click position is available in vars ClickMouseX and ClickMouseY}
  921. function MousePress(Button:Word; var Count:Word):Word;
  922.  
  923.      The MousePress function returns the information provided  by
  924. the associated mouse driver function. The Button value  specifies
  925. which button information to get, and the Count value returns  the
  926. number  of times the button was pressed since the last call.  The
  927. position  the mouse was in at the last time the specified  button
  928. was  pressed  is  returned in  the  MousePressX  and  MousePressY
  929. variables.  These values are in the mouse driver virtual  format.
  930. You  can use the GetMx and GetMy functions to convert the  values
  931. to real screen position information.
  932.  
  933.  
  934.  
  935.  
  936. { function 6 - gets button release information  }
  937. { Recommended calling method: }
  938. { Status := MouseRelease(Button,Count); }
  939. { Click position is available in vars ClickMouseX and ClickMouseY}
  940. function MouseRelease(Button: Word; var Count:Word):Word;
  941.  
  942.      The  MouseRelease function returns the information  provided
  943. by  the  associated  mouse  driver  function.  The  Button  value
  944. specifies  which button information to get, and the  Count  value
  945. returns  the  number of times the button was released  since  the
  946. last  call.  The position the mouse was in at the last  time  the
  947. specified  button was released is returned in  the  MouseReleaseX
  948. and MouseReleaseY variables. These values are in the mouse driver
  949. virtual  format.  You can use the GetMx and  GetMy  functions  to
  950. convert the values to real screen position information.
  951.  
  952.  
  953.  
  954.  
  955. { functions 7 and 8 - sets area where the mouse is allowed to run }
  956. { Recommended calling method: }
  957. { SetMouseArea(PutMx(x1),PutMy(y1),PutMx(x2),PutMy(y2)); }
  958. procedure SetMouseArea(x1,y1,x2,y2:Integer);
  959.  
  960.      The SetMouseArea function allows you to limit mouse movement
  961. to  a  specific  area of the screen. This  function  expects  the
  962. virtual  mouse coordinates to be used. Normally this  means  that
  963. you  should use the PutMx and PutMy functions to adapt  your  own
  964. screen  position  information to the values wanted by  the  mouse
  965. driver.
  966.  
  967.  
  968.  
  969. { function 9 - sets the graphics cursor style }
  970. procedure MouseGraphicCursor(Style:Integer);
  971.  
  972.      The  MouseGraphicCursor function allows you to load  one  of
  973. the predefined Mouse cursors. The specific mouse cursor style  is
  974. passed  as  the  value contained in the  "Style".  Refer  to  the
  975. constant  table in the MOUSECUR.PAS include file for the  various
  976. mouse styles that are supplied by the Mouse unit.
  977.  
  978.  
  979.  
  980. { function 9 - sets a custom graphics cursor style }
  981. procedure SetMouseGraphicCursor(var Mask:MaskType);
  982.  
  983.      This  function  allows you to load a custom  graphics  mouse
  984. cursor.  The  cursor information is passed in  the  Mask  record.
  985. Refer  to  the Mouse technical manual on how to create  a  custom
  986. mouse cursor.
  987.  
  988.  
  989.  
  990.  
  991. { function 10 - sets the text cursor style }
  992. procedure MouseTextCursor(Style:Word);
  993.  
  994.      This function allows you to load one of the predefined  text
  995. mouse  cursors. The specific mouse cursor type is passed  as  the
  996. value  contained in the "Style". Refer to the constant  table  in
  997. the  MOUSECUR.PAS include file for the various mouse style  that
  998. are supplied by the Mouse unit.
  999.  
  1000.      A  value of 0 will cause the existing hardware cursor to  be
  1001. used  as  the text mouse cursor. Note: a Style value  of  1  will
  1002. cause a block styled hardware cursor to be used. This will change
  1003. the  existing hardware cursor to become a block.  Values  greater
  1004. than one will cause one of the predefined software cursors to  be
  1005. loaded.
  1006.  
  1007.  
  1008.  
  1009.  
  1010. { function 10 - sets the text cursor style }
  1011. procedure SetMouseTextCursor(Select,Start,Stop:Word);
  1012.  
  1013.      This function allows you to load a custom text mouse cursor.
  1014. The  cursor information is passed in the Select, Start, and  Stop
  1015. values.  Refer to the Mouse technical manual on how to  create  a
  1016. custom mouse cursor. The MouseTStyle is set to a -1 when a custom
  1017. mouse cursor is loaded.
  1018.  
  1019.  
  1020.  
  1021. { function 11 - Read Mouse Motion counters }
  1022. procedure ReadMickey(var X,Y:Integer);
  1023.  
  1024.      This function returns the "Mickey" count since the last time
  1025. the function was called. A Mickey is the actual count  positional
  1026. information that comes from the mouse. This is different than the
  1027. mouse  virtual  position information which is  derived  from  the
  1028. Mickey  count.  Refer to the mouse technical manual  for  further
  1029. information  on  Mickeys  and their  relationship  to  positional
  1030. information.
  1031.  
  1032.  
  1033.  
  1034. { function 12 - Set Mouse Interrupt service routine and mask }
  1035. procedure SetMouseISR(Mask:Word; Address:Pointer);
  1036.  
  1037.      You can attach an interrupt service routine to the mouse  by
  1038. using the SetMouseISR function. Extreme care should be  exercised
  1039. when using this function as with all interrupt service  routines.
  1040. It  should be noted that not all mouse drivers support the  mouse
  1041. ISR routines, and that there are some differences in the way  the
  1042. mouse  ISR  is  handled  in those drivers  that  do  support  the
  1043. function. Refer  to  the  mouse  technical  manual   for   further
  1044. information  on  mouse ISR handlers.
  1045.  
  1046.  
  1047.  
  1048. { function 13 and 14 - Light pen emulation on/off }
  1049. procedure LightPen(Flag:Boolean);
  1050.  
  1051.      You  can  enable or disable a light pen  emulation  mode  by
  1052. calling  this function with Flag set to true to enable the  light
  1053. pen emulation, or false to turn it off.
  1054.  
  1055.  
  1056.  
  1057. { function 15 - sets the mickey to pixel ratio }
  1058. procedure SetPixeltoMickey(X,Y:Integer);
  1059.  
  1060.      The SetPixeltoMickey function sets the conversion value used
  1061. to  translate  the  Mickey values received from  the  mouse  into
  1062. the  virtual pixel locations used by the mouse driver.  Refer  to
  1063. the mouse technical manual for further information on Mickeys and
  1064. their relationship to positional information.
  1065.  
  1066.  
  1067.  
  1068. { function 16 - Conditional Mouse Hide - hides mouse if in area }
  1069. { use ShowMouse after using this function - }
  1070. { just like regular HideMouse. }
  1071. {Recommended calling method: }
  1072. {If HideMouseArea(PutMx(x1),PutMy(y1),
  1073.                   PutMx(x2),PutMy(y2)) then DoSomething;}
  1074. procedure HideMouseArea(x1,y1,x2,y2:Integer);
  1075.  
  1076.      The HideMouseArea function allows you to conditionally  hide
  1077. the  mouse  cursor if it is in a specific screen area.  This  can
  1078. help  to reduce the screen flicker that can occur when the  mouse
  1079. is hidden during writing by specifying that the mouse only  needs
  1080. to be hidden if it is within the screen area being written to.
  1081.  
  1082. Note:  The MouseHideArea function will not work properly  on  EGA
  1083. displays  when  using the internal mouse driver cursor.  This  is
  1084. because  the  mouse  driver must keep track of the  status  of  a
  1085. number  of the EGA registers. These registers are  not  readable.
  1086. This  requires that the user program perform all  CRT  controller
  1087. register changes via special extended BIOS calls.  Unfortunately,
  1088. most  programs do not do this. The Turbo Pascal is one  of  those
  1089. programs  that  do not do this. If you are using an  EGA  display
  1090. mode  it  is  recommended  that you  use  the  generic  MouseHide
  1091. function instead.
  1092.  
  1093.      This  function expects the virtual mouse coordinates  to  be
  1094. used. Normally this means that you should use the PutMx and PutMy
  1095. functions  to adapt your own screen position information  to  the
  1096. values wanted by the mouse driver.
  1097.  
  1098.      This function should be avoided when using an ISR to control
  1099. the mouse since re-entrancy conflicts will most likely result  if
  1100. you do so. If in doubt avoid this function.
  1101.  
  1102.  
  1103.  
  1104.  
  1105. { function 19 - Set Double Speed Threshold }
  1106. procedure MouseThreshold(Threshold:Integer);
  1107.  
  1108.      The  mouse  driver  can be set to  provide  a  double  speed
  1109. movement when the mouse is moved very quickly. The point at which
  1110. the speed is doubled is the mouse double speed threshold which is
  1111. measured  in  Mickeys per second. This value can  be  changed  by
  1112. calling the MouseThreshold function with the new desired  values.
  1113. Refer  to the mouse technical manual for further  information  on
  1114. Mickeys and their relationship to positional information.
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120. { function 20 - Swap current Mouse ISR with a new one}
  1121. { Returns old ISR and mask in the calling variables }
  1122. procedure SwapMouseISR(var Mask:Word; var Address:Pointer);
  1123.  
  1124.      You can swap the current interrupt service routine (ISR) for
  1125. the mouse with a new handler by using the SwapMouseISR  function.
  1126. Extreme care should be exercised when using this function as with
  1127. all  interrupt service routines.
  1128.  
  1129.      It  should be noted that not all mouse drivers  support  the
  1130. mouse  ISR routines, and that there are some differences  in  the
  1131. way the mouse ISR is handled in those drivers that do support the
  1132. function.  Refer  to  the  mouse  technical  manual  for  further
  1133. information on mouse ISR handlers.
  1134.  
  1135.  
  1136.  
  1137. { function 29 - Set Mouse Page }
  1138. procedure SetMousePage(Page:Word);
  1139.  
  1140.      Normally the mouse defaults to video page 0. You can  change
  1141. the  page that the mouse is on by calling this function with  the
  1142. appropriate page number in 'Page'.
  1143.  
  1144.  
  1145.  
  1146. { function 30 - Get Mouse Page }
  1147. function GetMousePage:Word;
  1148.  
  1149.      The GetMousePage function allows you to find out which video
  1150. page  the  mouse is currently on. The function returns  the  page
  1151. number as a function result.
  1152.  
  1153.  
  1154.  
  1155.  
  1156. {Set Hercules Graphics page for Mouse (not a standard function)}
  1157. { 0= graph pg 0,   1= graph pg 1,   -1 = text mode }
  1158. procedure SetHercMouse(Pg:Integer);
  1159.  
  1160.      This  procedure  is  not a standard mouse  function.  It  is
  1161. however  needed to work with the Hercules graphics display.  When
  1162. you use the Hercules graphics display you must call this with the
  1163. proper display page after you call InitGraph, but before you call
  1164. InitMouse. InitGraph needs CrtMode to be at 7 to detect the  Herc
  1165. display, but the Mouse needs it at 5 or 6 to detect when the Herc
  1166. card  is  in  graphs mode. (The Herc card has  no  provision  for
  1167. telling  the system that it is graphics mode.) Note: Be  sure  to
  1168. call  this procedure with a Pg of -1 if you turn graphics off  or
  1169. anytime before you call InitGraph or DetectGraph. The Mouse  unit
  1170. contains  an Exit procedure that calls SetHercMouse with a  value
  1171. of  -1 if a Hercules graph mode was selected so that the  CrtMode
  1172. byte will be properly restored on exit from the program.
  1173.  
  1174.  
  1175. ----------------------------------------------------------------
  1176. The following procedures use the mouse functions to provide
  1177. a higher level of control over the mouse:
  1178.  
  1179. { Normalizes a mouse X position to standard position info }
  1180. function GetMx(X:Integer):Integer;
  1181.  
  1182.      The  GetMx  function is used to convert a  virtual  mouse  X
  1183. position to a real screen X position. The data passed in  X  is
  1184. converted and the result passed back as a function result.
  1185.  
  1186.  
  1187. { Normalizes a mouse Y position to standard position info }
  1188. function GetMy(Y:Integer):Integer;
  1189.  
  1190.      The  GetMy  function is used to convert a  virtual  mouse  Y
  1191. position  to  a real screen Y position. The data passed in  Y  is
  1192. converted and the result passed back as a function result.
  1193.  
  1194.  
  1195. { converts a standard X position to a mouse X position }
  1196. function PutMx(X:Integer):Integer;
  1197.  
  1198.      The PutMx function is used to convert real screen X position
  1199. information  to a virtual mouse X position. The data passed in  X
  1200. is converted and the result passed back as a function result.
  1201.  
  1202.  
  1203. { converts a standard Y position to a mouse Y position }
  1204. function PutMy(Y:Integer):Integer;
  1205.  
  1206.      The PutMy function is used to convert real screen Y position
  1207. information  to a virtual mouse Y position. The data passed in  Y
  1208. is converted and the result passed back as a function result.
  1209.  
  1210.  
  1211. { Check if mouse is currently in the specified area}
  1212. { returns true if it is, false if not}
  1213. {  Recommended calling method: }
  1214. {  If MousePointIn(GetMx(Mx),GetMy(My),
  1215.                              x1,y1,x2,y2) then DoSomething;}
  1216. function MousePointIn(Mx,My, x1,y1,x2,y2:Integer):Boolean;
  1217.  
  1218.      This  function  returns  a true result if  the  point  value
  1219. passed  in  My  and  My is  within  the  rectangle  described  by
  1220. x1,y1,x2,y2.  The  point is not with the rectangle it  returns  a
  1221. false  condition.  The  function can actually  be  used  for  any
  1222. generic  point in rectangle application.  When using it  to  test
  1223. the mouse position, you should use the GetMx and GetMy  functions
  1224. to convert the mouse virtual position information to real  screen
  1225. position  information  (assuming that you are using  real  screen
  1226. position information in x1,y1,x2,y2).
  1227.  
  1228.  
  1229. {has the mouse been clicked recently?}
  1230. function MouseClick:Boolean;
  1231.  
  1232.      The  MouseClick function returns the current status  of  the
  1233. MouseClicked variable and automatically clears it in the  process
  1234. in  preparation for the next test. This function is  provided  to
  1235. make  testing  of  the  flag easier.  You  can  handle  the  flag
  1236. yourself, but it is recommended to process through this  function
  1237. for future compatibility.
  1238.  
  1239.  
  1240. {Hooks the Mouse function to the system clock}
  1241. {State = true hooks the mouse up }
  1242. {State = false disconnects the mouse}
  1243. procedure MouseClock(State:Boolean);
  1244.  
  1245.      The MouseClock function hooks the mouse ReadMouse  procedure
  1246. to  the  system  clock.  This  causes  the  mouse  status  to  be
  1247. periodically updated once every 55ms.
  1248.  
  1249.  
  1250. {Pushes current mouse status on the mouse stack}
  1251. {Returns false if not enough heap space to push}
  1252. function PushMouse:Boolean;
  1253.  
  1254.      The  PushMouse  function  allows you  to  save  the  current
  1255. operational  condition of the mouse on a stack. The  Mouse  stack
  1256. uses heap space to store the information. You can then recall the
  1257. saved  mouse condition by using PopMouse at a later point in  the
  1258. program. Note: Some mouse drivers do not implement the ability to
  1259. save the mouse state. Check with your current mouse driver as  to
  1260. whether it can support this function before you use it.
  1261.  
  1262.      If for some reason the PushMouse function doesn't work, such
  1263. as  no heap space to save the mouse condition, the function  will
  1264. return a false value. A true value is returned if everything goes
  1265. as planed.
  1266.  
  1267.  
  1268. {Pops mouse status from the mouse stack.}
  1269. function PopMouse:Boolean;
  1270.  
  1271.      The  PopMouse  function  is the opposite  of  the  PushMouse
  1272. function.  You can restore a previously saved mouse condition  by
  1273. using  the  PopMouse  function. If there is nothing  to  pop,  or
  1274. something went wrong the function will return a false  condition.
  1275. If  everything  is  went well the function  will  return  a  true
  1276. condition.
  1277.  
  1278.  
  1279. {Get rid of mouse stack}
  1280. procedure ZapMouseStack;
  1281.  
  1282.      The  ZapMouseStack procedure clears the mouse stack  of  any
  1283. extra  saved mouse conditions. If you are uncertain of the  Mouse
  1284. Stack  condition you can call this function to remove  all  saved
  1285. conditions.  When  done the mouse will have the  conditions  that
  1286. were present with the first mouse save on the mouse stack.
  1287.  
  1288.  
  1289. Acknowledgments:
  1290.  
  1291.      While  there is very little left of the Mouse  program  that
  1292. relates to the earlier versions, I do wish to thank the following
  1293. people for their earlier work.
  1294.  
  1295.      The original idea for MOUSE was based on the MOUSE4  program
  1296. by  Richard Sadowsky. The Cursor styles were based on  the  ideas
  1297. presented  in EGAMouse by Eduardo Martins. Special thanks to  Kim
  1298. Kokkonen  for reminding me about the differences between Dos  2.x
  1299. and Dos 3.x interrupt use detection.
  1300.  
  1301.      I  also  wish  to  thank  the  countless  users  and   other
  1302. interested parties who have provided inputs for enhancements  and
  1303. their continued support and encouragement.
  1304.  
  1305.      Any stupid mistakes are my own.
  1306.  
  1307. General disclaimer:
  1308.  
  1309.      There  have  been many people who have  provided  input  and
  1310. encouragement on the Borland Pascal forum of Compuserve which has
  1311. allowed  this program to grow and mature. It should  be  realized
  1312. though that like all software, there can never be assured a  100%
  1313. reliability, or that the program will fit your needs exactly.
  1314.  
  1315.      I cannot warrant that this program will work flawlessly  for
  1316. you.  Only  you can be the judge of that. As such,  if  it  don't
  1317. work, blows up in your face, or the sky falls on your head, don't
  1318. blame me, I warned ya!
  1319.  
  1320.  
  1321.  
  1322.  
  1323.          ----------------end-of-author's-documentation---------------
  1324.  
  1325.                         Software Library Information:
  1326.  
  1327.                    This disk copy provided as a service of
  1328.  
  1329.                         The Public (Software) Library
  1330.  
  1331.          We are not the authors of this program, nor are we associated
  1332.          with the author in any way other than as a distributor of the
  1333.          program in accordance with the author's terms of distribution.
  1334.  
  1335.          Please direct shareware payments and specific questions about
  1336.          this program to the author of the program, whose name appears
  1337.          elsewhere in  this documentation. If you have trouble getting
  1338.          in touch with the author,  we will do whatever we can to help
  1339.          you with your questions. All programs have been tested and do
  1340.          run.  To report problems,  please use the form that is in the
  1341.          file PROBLEM.DOC on many of our disks or in other written for-
  1342.          mat with screen printouts, if possible.  The P(s)L cannot de-
  1343.          bug programs over the telephone.
  1344.  
  1345.          Disks in the P(s)L are updated monthly, so if you did not get
  1346.          this disk  directly from the P(s)L,  you should be aware that
  1347.          the files in this set may no  longer be the current versions.
  1348.  
  1349.          For a copy of the latest monthly software library newsletter
  1350.          and a list of the 1,800+ disks in the library, call or write
  1351.  
  1352.                         The Public (Software) Library
  1353.                               P.O.Box 35705 - F
  1354.                            Houston, TX 77235-5705
  1355.                                (713) 665-7017
  1356.  
  1357.